﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Garden.Helper
{
    class RegexHelper:Kaixin.BLL.Helper.RegexHelper
    {

        /// <summary>
        /// 返回匹配的第一个值
        /// </summary>
        /// <param name="txt"></param>
        /// <param name="regex"></param>
        /// <returns></returns>
        public static string GetFirstVal(string txt,string regex)
        {
            List<GroupCollection> list = Matches(txt, regex);
            return list.Count == 0 ? string.Empty : list[0][1].Value;
        }



        /// <summary>
        /// 进入花园获取验证字符串
        /// </summary>
        public static string VerifyReg { get { return "var g_verify = \"(.*)\";"; } }
        /// <summary>
        /// 返回花园Item
        /// "(? <= <item>).*?(?= </item>)"
        /// </summary>
        public static string ItemReg { get { return "(?<=<item>).*?(?=</item>)"; } }
        /// <summary>
        /// 农地的水量
        /// </summary>
        public static string WaterReg { get { return "<water>(\\d{1})</water>"; } }
        /// <summary>
        /// 农地编号
        /// </summary>
        public static string FarmNumReg { get { return "<farmnum>(\\d{1,})</farmnum>"; } }
        /// <summary>
        /// 农地状态
        /// </summary>
        public static string StatusReg { get { return "<status>(\\d{1,})</status>"; } }
        /// <summary>
        /// 农地(爱心地)
        /// </summary>
        public static string SharedReg { get { return "<shared>(\\d{1,})</shared>"; } }
        public static string GrowReg { get { return "<grow>(\\d{1,})</grow>"; } }
        public static string TotalgrowReg { get { return "<totalgrow>(\\d{1,})</totalgrow>"; } }
        public static string SeedidReg { get { return "<seedid>(\\d{1,})</seedid>"; } }
        public static string NameReg { get { return "<name>(.*)</name>"; } }
        public static string SeedNameReg { get { return "<seedname>(.*)</seedname>"; } }
        /// <summary>
        /// 产量
        /// </summary>
        public static string FruitNumReg { get { return "<fruitnum>(\\d{1,})</fruitnum>"; } }
        /// <summary>
        /// 长草
        /// </summary>
        public static string GrassReg { get { return "<grass>(\\d{1})</grass>"; } }
        /// <summary>
        /// 长虫
        /// </summary>
        public static string VerminReg { get { return "<vermin>(\\d{1})</vermin>"; } }
        /// <summary>
        /// 1--正常，-1--枯死
        /// </summary>
        public static string CropsstatusReg { get { return "<cropsstatus>(.*)</cropsstatus>"; } }
        /// <summary>
        /// 偷取数量
        /// </summary>
        public static string StealnumReg { get { return "<stealnum>(.*)</stealnum>"; } }
        public static string NumReg { get { return "<num>(.*)</num>"; } }
        /// <summary>
        /// 结果
        /// </summary>
        public static string RetReg { get { return "<ret>(.*)</ret>"; } }
        /// <summary>
        /// 农作物
        /// </summary>
        public static string CropsReg { get { return "<crops>(.*)</crops>"; } }
        public static string SeedtipsReg { get { return "<seedtips>(.*)</seedtips>"; } }
        public static string SeedReg { get { return "<seed>(.*)</seed>"; } }
        public static string FruitReg { get { return "<fruit>(.*)</fruit>"; } }
        public static string NoAdd { get { return "还没有添加本组件"; } }
        
    }
}
